﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Jemgine.Engine.Scripts
{
    [Category("Physics"), Node]
   public class SetGravity: Data.ScriptNode
    {
        public Vector2 Gravity { get; set; }

        [Microsoft.Xna.Framework.Content.ContentSerializer(Optional = true)]
        public float GravityForce { get; set; }

       public SetGravity()
       {
           AddInput("Fire", typeof(Physics));
           AddOutput("Relay", null);
           Gravity = new Vector2(0, -1); //Default gravity;
           GravityForce = 80;
       }

       public override void FireTerminal(int InputID, Data.ScriptPayload Payload)
       {
           Gravity.Normalize();
           if (Payload.Physics != null) Payload.Physics.SetGravity(Gravity * GravityForce);
           OutputTerminals[0].Fire(Payload);
       }

      
    }
}
